<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>BasicStat (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">stats.BasicStat</span>
        <span>Extends</span>
        <span class="fn-name">
          
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Tracks basic statistics over a specified time interval.

Statistics are kept in a fixed number of slots, each representing
an equal portion of the time interval.

Most methods optionally allow passing in the current time, so that
higher level stats can synchronize operations on multiple child
objects.  Under normal usage, the default of goog.now() should be
sufficient.


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_stats_basicstat.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/stats/basicstat.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td>goog.stats.BasicStat</td><td></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.stats.BasicStat(<span><span class="arg">interval</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">interval</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The stat interval, in milliseconds.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_stats_BasicStat.html">
              goog.stats.BasicStat
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.checkForTimeTravel_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">checkForTimeTravel_<span class="args">(<span class="arg">now</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Checks that time never goes backwards.  If it does (for example,
the user changes their system clock), the object state is cleared.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">now</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The current time, in milliseconds.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line214">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.get"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">get<span class="args">(<span class="arg">opt_now</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Returns the count of the statistic over its configured time
interval.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_now</span>
        : <span class="type">number=</span>
        <div class="entryOverview">The time, in milliseconds, to be treated
    as the "current" time.  The current time must always be greater
    than or equal to the last time recorded by this stat tracker.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The total count over the tracked interval.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line130">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.getInterval"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getInterval<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The interval which over statistics are being
    accumulated, in milliseconds.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line95">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.getMax"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getMax<span class="args">(<span class="arg">opt_now</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Returns the magnitute of the largest atomic increment that occurred
during the watched time interval.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_now</span>
        : <span class="type">number=</span>
        <div class="entryOverview">The time, in milliseconds, to be treated
    as the "current" time.  The current time must always be greater
    than or equal to the last time recorded by this stat tracker.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The maximum count of this statistic.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line145">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.getMin"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getMin<span class="args">(<span class="arg">opt_now</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Returns the magnitute of the smallest atomic increment that
occurred during the watched time interval.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_now</span>
        : <span class="type">number=</span>
        <div class="entryOverview">The time, in milliseconds, to be treated
    as the "current" time.  The current time must always be greater
    than or equal to the last time recorded by this stat tracker.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The minimum count of this statistic.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line160">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.getSlotBoundary_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getSlotBoundary_<span class="args">(<span class="arg">time</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Computes the end time for the slot that should contain the count
around the given time.  This method ensures that every bucket is
aligned on a "this.slotInterval_" millisecond boundary.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">time</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The time to compute a boundary for.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The computed boundary.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line203">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.incBy"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">incBy<span class="args">(<span class="arg">amt</span>,&nbsp;<span class="arg">opt_now</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Increments the count of this statistic by the specified amount.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">amt</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The amount to increase the count by.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_now</span>
        : <span class="type">number=</span>
        <div class="entryOverview">The time, in milliseconds, to be treated
    as the "current" time.  The current time must always be greater
    than or equal to the last time recorded by this stat tracker.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line108">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.reduceSlots_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">reduceSlots_<span class="args">(<span class="arg">now</span>,&nbsp;<span class="arg">func</span>,&nbsp;<span class="arg">val</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Passes each active slot into a function and accumulates the result.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">now</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>
        <div class="entryOverview">The current time, in milliseconds.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">func</span>
        : <span class="type">function(number, goog.stats.BasicStat.Slot_): number</span>
        <div class="entryOverview">The function to call for every active slot.  This function
    takes two arguments: the previous result and the new slot to
    include in the reduction.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">val</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The initial value for the reduction.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The result of the reduction.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line179">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.stats.BasicStat.prototype.reset_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">reset_<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       Clears any statistics tracked by this object, as though it were
freshly created.

     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line233">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_stats_BasicStat.html">
              goog.stats.BasicStat
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.stats.BasicStat.prototype.interval_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">interval_</span>
        : 
     </div>


     <div class="entryOverview">
       The time interval that this statistic aggregates over.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line54">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.stats.BasicStat.prototype.logger_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">logger_</span>
        : <span class="type"><a href="class_goog_debug_Logger.html">goog.debug.Logger</a></span>
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line87">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.stats.BasicStat.prototype.slotInterval_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">slotInterval_</span>
        : 
     </div>


     <div class="entryOverview">
       The number of milliseconds in each slot.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line61">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.stats.BasicStat.prototype.slots_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">slots_</span>
        : <span class="type"><a href="class_goog_structs_CircularBuffer.html">goog.structs.CircularBuffer</a></span>
     </div>


     <div class="entryOverview">
       The array of slots.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line68">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>










<div class="section">
  <table class="horiz-rule">


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.stats.BasicStat.NUM_SLOTS_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.stats.BasicStat.</span><span class="entryName">NUM_SLOTS_</span>
        : 
     </div>


     <div class="entryOverview">
       The number of slots. This value limits the accuracy of the get()
method to (this.interval_ / NUM_SLOTS).  A 1-minute statistic would
be accurate to within 2 seconds.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_stats_basicstat.js.source.html#line80">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package stats</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="stats.BasicStat"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
